from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
class LikeShopTest()
    # def init(self)
    #     self.browser = webdriver.Firefox()

    def test1(self)
        self.browser = webdriver.Firefox()
        self.browser.get(httplocalhostadminaccountlogin.html)
        sleep(3)
        self.browser.find_element(By.NAME,'account').send_keys('admin')
        self.browser.find_element(By.NAME,'password').send_keys('123456')
        self.browser.find_element(By.NAME,'code').send_keys('11111')
        self.browser.find_element(By.ID,'login').click()
        sleep(3)
        self.browser.find_element(By.LINK_TEXT,'商品').click()

        frame1 = self.browser.find_element(By.XPATH,'[@id=LAY_app_body]div[2]iframe')
        self.browser.switch_to.frame(frame1)
        sleep(1)
        self.browser.find_element(By.XPATH,'[@id=keyword]').send_keys('文具')
        sleep(1)
        self.browser.find_element(By.XPATH,'htmlbodydivdivdiv[2]divdivdiv[1]divdiv[5]button[1]').click()
        sleep(5)
        shop_list=  self.browser.find_elements(By.XPATH,'htmlbodydivdivdiv[2]divdivdiv[2]div[2]div[1]div[2]tabletbodytr')
        count =len(shop_list)
        if count == 0
            print('没有数据')
        else
            shop_name_ret =     True
            for shop_item in shop_list
                shop_name = shop_item.find_element(By.XPATH,'.td[2]div').text
                if '文具' not in shop_name
                    shop_name_ret=False

            # for i in range(1,count+1)
            #     xpath= 'htmlbodydivdivdiv[2]divdivdiv[2]div[2]div[1]div[2]tabletbodytr[%s]td[2]div' %i
            #     shop_name=self.browser.find_element(By.XPATH,xpath).text
            #     if '文具' not in shop_name
            #         shop_name_ret =False
            if shop_name_ret
                print('没问题')
            else
                print('有bug')
        sleep(5)



likeshop = LikeShopTest()
likeshop.test1()